package com.example.cool_core.config;

import android.support.annotation.DrawableRes;

public class CoolViewConfig {
    private int LoadingLayout, ErrorLayout, TopBarLayout;
    private int AdapterImg404;

    private CoolViewConfig() {
    }

    public static synchronized CoolViewConfig getInstance() {
        return CoolViewConfigHolder.instance;
    }

    private static class CoolViewConfigHolder {
        private static final CoolViewConfig instance = new CoolViewConfig();
    }

    /**
     * @param loadingLayout 最外层必须命名 cool_layout_loading
     * @return
     */
    public CoolViewConfig setLoadingLayout(int loadingLayout) {
        this.LoadingLayout = loadingLayout;
        return this;
    }

    /**
     * @param errorLayout 最外层必须命名 cool_layout_error
     *                    而且必须有个view 命名 cool_refresh 负责点击后重新刷新
     * @return
     */
    public CoolViewConfig setErrorLayout(int errorLayout) {
        this.ErrorLayout = errorLayout;
        return this;
    }

    /**
     * @param topBarLayout 负责点击返回键的 cool_layout_left
     *                     返回键的imageView控件 cool_img_left
     *                     显示标题的textView空间 cool_tv_title
     * @return
     */
    public CoolViewConfig setTopBarLayout(int topBarLayout) {
        this.TopBarLayout = topBarLayout;
        return this;
    }

    /**
     * adapter 404 时显示的图片
     *
     * @param adapterImg404
     * @return
     */
    public CoolViewConfig setAdapterImg404(@DrawableRes int adapterImg404) {
        this.AdapterImg404 = adapterImg404;
        return this;
    }

    /**
     * 恢复默认
     *
     * @return
     */
    public CoolViewConfig setDefault() {
        this.TopBarLayout = 0;
        this.LoadingLayout = 0;
        this.ErrorLayout = 0;
        this.AdapterImg404 = 0;
        return this;
    }

    public int getLoadingLayout() {
        return LoadingLayout;
    }

    public int getErrorLayout() {
        return ErrorLayout;
    }

    public int getTopBarLayout() {
        return TopBarLayout;
    }

    public int getAdapterImg404() {
        return AdapterImg404;
    }
}
